/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import EntitiesTier.ClAdicao;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Douglas
 */
public class AdicaoTableModel extends AbstractTableModel{
    
    private List<ClAdicao> adic;
    private List<String> colunas;
    
    public AdicaoTableModel(List<ClAdicao> adit) throws Exception
    {
       this.adic = adit;
       colunas = Arrays.asList("Cod.", "Contrato", "Data", "Motivo", "Tempo");
    }

    @Override
    public int getRowCount() {
        return adic.size();
    }

    @Override
    public int getColumnCount() {
        return 5;
    }

    @Override
    public Object getValueAt(int lin, int col) {
        ClAdicao ad = adic.get(lin);
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        switch(col)
        {
            case 0 : return ad.getADIC_COD();
            case 1 : return ad.getADIC_CONT();
            case 2 : return df.format(ad.getADIC_DATA());
            case 3 : return ad.getADIC_MOTIVO();
            case 4 : return ad.getADIC_TEMPO();
            default : return "";
        }
              
    }

    @Override
    public String getColumnName(int col) {
        return colunas.get(col);
    }
    
    
    
}
